package com.itlong.cloud.property.resource;

import com.itlong.cloud.POJO.DTO.property.PropertyProjectGetBuildInfoDTO;
import com.itlong.cloud.POJO.DTO.property.PropertyProjectGetBuildSimpleInfoDTO;
import com.itlong.cloud.POJO.DTO.property.PropertyProjectSaveBuildInfoDTO;
import com.itlong.cloud.POJO.DTO.property.PropertyProjectUpdateBuildInfoDTO;
import com.itlong.cloud.POJO.VO.property.PropertyProjectBuildInfoVO;
import com.itlong.cloud.POJO.VO.property.PropertyProjectBuildSimpleInfoExVO;
import com.itlong.cloud.POJO.VO.property.PropertyProjectBuildSimpleInfoVO;
import com.itlong.cloud.project.property.IPropertyBuildInfoServiceClient;
import com.itlong.cloud.property.service.IPropertyBuildInfoService;
import com.itlong.cloud.utils.page.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
* <desc>
*       楼栋信息服务暴露接口实现类.
* </desc>
*
* @createDate 2017-09-22
*/
@RestController
public class PropertyBuildInfoServiceResource implements IPropertyBuildInfoServiceClient {

    @Autowired
    private IPropertyBuildInfoService iPropertyBuildInfoService;  //楼栋信息处理接口


    /**
     * <desc>
     *      保存楼栋信息(含批量保存该楼栋下的单元信息)
     * </desc>
     *
     * @param propertyProjectSaveBuildInfoDTO 添加楼栋信息数据传输对象
     * @return 受影响的行数
     * @author LouisLewis
     * @createDate 2017-09-19
     */
    @Override
    @RequestMapping(path = "property/buildInfo/saveBuildInfo",method = {RequestMethod.POST})
    public Integer saveBuildInfo(@RequestBody PropertyProjectSaveBuildInfoDTO propertyProjectSaveBuildInfoDTO)throws Exception {
        return iPropertyBuildInfoService.saveBuildInfo(propertyProjectSaveBuildInfoDTO);
    }

    /**
     * <desc>
     *      修改楼栋信息【根据楼栋Id（BuildId）】
     * </desc>
     *
     * @param propertyProjectUpdateBuildInfoDTO 修改楼栋信息数据传输对象
     * @return  受影响的行数
     * @author LouisLewis
     * @createDate 2017-09-26
     */
    @Override
    @RequestMapping(path = "property/buildInfo/updateBuildInfo",method = {RequestMethod.POST})
    public Integer updateBuildInfo(@RequestBody PropertyProjectUpdateBuildInfoDTO propertyProjectUpdateBuildInfoDTO) throws Exception {
        return iPropertyBuildInfoService.updateBuildInfo(propertyProjectUpdateBuildInfoDTO);
    }

    /**
     * <desc>
     *      逻辑删除楼栋信息【根据楼栋Id（BuildId）】
     * </desc>
     *
     * @param buildId 待删除的楼栋Id
     * @return 受影响的行数
     * @author LouisLewis
     * @createDate 2017-09-26
     */
    @Override
    @RequestMapping(path = "property/buildInfo/removeBuildInfo/{buildId}",method = {RequestMethod.GET})
    public Integer removeBuildInfo(@PathVariable("buildId")String buildId) {
        return iPropertyBuildInfoService.removeBuildInfo(buildId);
    }


    /**
     * <desc>
     *      分页查询楼栋信息
     * </desc>
     *
     * @param propertyProjectGetBuildInfoDTO 分页查询楼栋信息数据传输对象
     * @return 分页查询结果对象
     * @author LouisLewis
     * @createDate 2017-09-25
     */
    @Override
    @RequestMapping(path = "property/buildInfo/getPage",method = {RequestMethod.POST})
    public Page<PropertyProjectBuildInfoVO> getPage(@RequestBody PropertyProjectGetBuildInfoDTO propertyProjectGetBuildInfoDTO) throws Exception {
        return iPropertyBuildInfoService.getPage(propertyProjectGetBuildInfoDTO);
    }

    /**
     * <desc>
     *      获取指定项目下的楼栋简单信息（楼栋id ,楼栋名称）列表
     * </desc>
     *
     * @param propertyProjectGetBuildSimpleInfoDTO  查询楼栋简单信息（楼栋ID，楼栋名称）数据传输对象
     * @return 楼栋简单信息（楼栋id ,楼栋名称）列表
     * @author LewisLouis
     * @createDate 2017-09-28
     */
    @Override
    @RequestMapping(path = "property/buildInfo/getPageBuildSimpleInfo",method = {RequestMethod.POST})
    public Page<PropertyProjectBuildSimpleInfoVO> getPageBuildSimpleInfoList(
            @RequestBody PropertyProjectGetBuildSimpleInfoDTO propertyProjectGetBuildSimpleInfoDTO) throws Exception {
        return iPropertyBuildInfoService.getPageBuildSimpleInfoList(propertyProjectGetBuildSimpleInfoDTO);
    }

    /**
     * <desc>
     * 分页查询指定项目下的楼栋简单扩展信息（楼栋id ,楼栋名称，楼栋下的房间数量）列表
     * </desc>
     *
     * @param propertyProjectGetBuildSimpleInfoDTO 查询楼栋简单扩展信息（楼栋id ,楼栋名称，楼栋下的房间数量）数据传输对象
     * @return 楼栋简单扩展信息（楼栋id ,楼栋名称，楼栋下的房屋数量）列表
     * @author LewisLouis
     * @createDate 2017-11-10
     */
    @Override
    @RequestMapping(path = "property/buildInfo/getPageBuildSimpleInfoEx",method = {RequestMethod.POST})
    public Page<PropertyProjectBuildSimpleInfoExVO> getPageBuildSimpleInfoExList(
            @RequestBody PropertyProjectGetBuildSimpleInfoDTO propertyProjectGetBuildSimpleInfoDTO) throws Exception {
        return iPropertyBuildInfoService.getPageBuildSimpleInfoExList(propertyProjectGetBuildSimpleInfoDTO);
    }

    /**
     * <desc>
     *      精确查询，获取单个楼栋信息
     * </desc>
     * @param propertyProjectGetBuildInfoDTO 查询楼栋信息数据传输对象
     * @return 按创建时间降序排列，首个符合查询条件的楼栋信息
     * @author LouisLewis
     * @createDate 2017-09-25
     */
    @Override
    @RequestMapping(path = "property/buildInfo/getOneBuildInfo",method = {RequestMethod.POST})
    public PropertyProjectBuildInfoVO getOneBuildInfo(@RequestBody PropertyProjectGetBuildInfoDTO propertyProjectGetBuildInfoDTO) {
        return iPropertyBuildInfoService.getOneBuildInfo(propertyProjectGetBuildInfoDTO);
    }

    /**
     * <desc>
     *      获取指定项目的最小可用楼栋编号buildNum
     * </desc>
     *
     * @param projectId 项目id
     * @return 最小可用的楼栋编号
     * @author wangzhi
     * @createDate 2018/05/29
     */
    @Override
    @RequestMapping(path = "property/buildInfo/getMinAvaliableBuildNumByProjectId",method = {RequestMethod.POST})
    public String getMinAvaliableBuildNumByProjectId(@RequestParam("projectId") String projectId) {
        return iPropertyBuildInfoService.getMinAvaliableBuildNumByProjectId(projectId);
    }
}
